extends ../layout

block content
  .container
    .row
      table.table.table-hover.table-bordered
        thead
          tr
            th 名字
            th 时间
            th 查看
            th 修改
            th 删除
        tbody
          each item in catetories
            tr(class="item-id-#{item._id}")
              td #{item.name}
              td #{item.meta.updateAt}
              td: a(target="_blank", href="../movie/#{item._id}") 查看
              td: a(target="_blank", href="../admin/update/#{item._id}") 修改
              td
                button.btn.btn-danger.del(type="button", data-id="#{item._id}") 删除
  script.
    $(function(){
      $(".del").on('click',function(){
          var id = $(this).attr('data-id');
          var tr = $(".item-id-"+id);
          $.ajax({
            type: 'DELETE',
            url: '/admin/category/list?id='+id

          }).done(function(result){
            if (result.success === 1) {
              if (tr.length > 0) {
                tr.remove()
              }
            }
          })
      })
    })